//
//  HLIMSessionInteractorProtocol.h
//  YueYue
//
//  Created by hulu001 on 2024/1/11.
//

#import <Foundation/Foundation.h>
#import "HLIMKitMessageModel.h"

#ifndef HLIMSessionInteractorProtocol_h
#define HLIMSessionInteractorProtocol_h


@class NIMMessage;

@protocol HLIMKitSessionInteractorDelegate <NSObject>

- (void)didFetchMessageData;

- (void)didRefreshMessageData;

- (void)didPullUpMessageData;

/// 当开启关闭新消息自动滑动到底部功能
/// @param messagesCount 底部新消息
- (void)didRecievedBottomNewMessage:(NSInteger)messagesCount;

/// 已经阅读底部消息
- (void)didReadBottomMessage;

@end

@protocol HLIMKitSessionInteractor <NSObject>

#pragma mark - 网络接口
- (void)sendMessage:(NIMMessage *_Nullable)message;

- (void)sendMessage:(NIMMessage *_Nullable)message completion:(void(^_Nullable)(NSError * _Nullable error))completion;

- (void)sendMessageReceipt:(NSArray *_Nullable)messages;

- (void)checkReceipts:(NSArray<NIMMessageReceipt *> *_Nullable)receipts;

#pragma mark - 界面操作接口

- (void)insertMessages:(NSArray *_Nullable)messages callback:(void(^ _Nullable)(id _Nullable data))callback;

- (void)addMessages:(NSArray *_Nullable)messages;

- (HLIMKitMessageModel *_Nullable)deleteMessage:(NIMMessage *_Nullable)message;

- (HLIMKitMessageModel *_Nullable)updateMessage:(NIMMessage *_Nullable)message;

- (void)clearAllMessages;

#pragma mark - 数据接口
- (NSArray *)items;

/// 标记已读
/// @param needSendReceipet 是否需要发送回执告诉对方自己已读
- (void)markRead:(BOOL)needSendReceipet;

- (HLIMKitMessageModel *)findMessageModel:(NIMMessage *_Nullable)message;

- (void)resetMessages:(void (^_Nullable)(NSError * _Nullable error))handler;

- (void)loadMessages:(void (^_Nullable)(NSArray * _Nullable messages, NSError * _Nullable error))handler;

- (void)loadNewMessages:(void (^_Nullable)(NSArray * _Nonnull, NSError * _Nonnull))handler;

- (NSInteger)findMessageIndex:(NIMMessage *_Nullable)message;

#pragma mark - 排版接口
- (void)resetLayout;

- (void)changeLayout:(CGFloat)inputHeight;

- (void)cleanCache;

- (void)pullUp;

- (void)scrollToBottom:(BOOL)animated; // 滚动到最下面一行 最新消息处

- (void)changeHeaderHeight:(NSInteger)height;

// 底部View
- (void)changeFooterHeight:(NSInteger)height;

/// 默认0 1:已经滑到底 2:未滑到底
@property (nonatomic,   assign) NSInteger scrollToBottomStatus;

#pragma mark - 页面状态同步接口
- (void)onViewWillAppear;

- (void)onViewDidDisappear;

/// 程序进入后台
- (void)onApplicationDidEnterBack;

/// 程序回到活跃状态
- (void)onApplicationDidBecomeActive;

@end

#endif /* HLIMSessionInteractorProtocol_h */
